use "data_dc.dta", replace 
set scheme white_ptol

**********************
**# Data Preparation * 
**********************
* clean vote choice in 2021
tab dc22_vote_2021, nol m
replace dc22_vote_2021=. if dc22_vote_2021==-99 //replace -99 to missing
replace dc22_vote_2021=. if dc22_vote_2021==6 // repalce Other parties' voters to missing
recode dc22_vote_2021 (7=6) // recode PPC from 7 to 6
tab dc22_vote_2021, nol m
clonevar vote_2021=dc22_vote_2021
fre dc22_turnout_2021
replace vote_2021=7 if dc22_turnout_2021==2 // abstainers in 2021 federal election

label define lbvote 1"LPC voters" 2"CPC voters" 3"NDP voters" 4"BQ voters" 5"Green voters" 6"PPC voters" 7"Abstainers"
label values vote_2021 lbvote
tab dc22_vote_2021 vote_2021, m
drop if dc22_vote_2021==4 // drop BQ voters
fre vote_2021 // check observations
tab vote_2021 dc22_turnout_2021, m // missing include (i) non-eligible voters in 2021; (ii) Other parties' voters; and (iii) non-respondents for this question 

* treatment condition & manipulation check
gen tr=. 
replace tr=0 if bo_module_exp =="control"
replace tr=1 if bo_module_exp =="treatment1"  
replace tr=2 if bo_module_exp =="treatment2" 

label define lbtr 0"control" 1"LPC undemocratic prime" 2"CPC undemocratic prime" 
label values tr lbtr
label var tr "Treatment"
fre tr // check distributions

rename bo_module_mcheck mcheck
label variable mcheck "Manipulation Check"

* clean DV: Perceived democraticness
replace bo_module_outcome_1_1=. if bo_module_outcome_1_1==-99
replace bo_module_outcome_1_2=. if bo_module_outcome_1_2==-99
replace bo_module_outcome_1_3=. if bo_module_outcome_1_3==-99
replace bo_module_outcome_1_4=. if bo_module_outcome_1_4==-99
replace bo_module_outcome_1_5=. if bo_module_outcome_1_5==-99
replace bo_module_outcome_1_6=. if bo_module_outcome_1_6==-99
rename bo_module_outcome_1_1 lpc_demo
rename bo_module_outcome_1_2 cpc_demo
rename bo_module_outcome_1_3 ndp_demo
rename bo_module_outcome_1_5 gr_demo
rename bo_module_outcome_1_6 ppc_demo

fre lpc_demo cpc_demo ndp_demo gr_demo ppc_demo // check distributions

label variable lpc_demo "Placement of LPC"
label variable cpc_demo "Placement of CPC"
label variable ndp_demo "Placement of NDP"
label variable gr_demo "Placement of Green"
label variable ppc_demo "Placement of PPC"

recode lpc_demo cpc_demo ndp_demo gr_demo ppc_demo (0=10) (10=0) (1=9) (9=1) (2=8) (8=2) (3=7) (7=3) (4=6) (6=4) // reverse order
fre lpc_demo cpc_demo ndp_demo gr_demo ppc_demo

label define lbdemo 0"undemocratic" 10"democratic"  
label values lpc_demo cpc_demo ndp_demo gr_demo ppc_demo lbdemo
fre lpc_demo cpc_demo ndp_demo gr_demo ppc_demo // check distributions

* control variables
rename dc22_age_in_years age
tab dc22_genderid, nol m
gen gender=. 
replace gender=1 if dc22_genderid==1
replace gender=2 if dc22_genderid==2
replace gender=3 if dc22_genderid==3 | dc22_genderid==4
label define lbgender  1"Man" 2"Woman" 3"Non-binary/Another gender" 
label values gender lbgender

rename dc22_province province

gen edu=. 
replace edu=1 if dc22_education>=9
replace edu=0 if dc22_education<9
tab edu dc22_education, m

rename dc22_income_category income
replace income=. if income==-99

label var age "Age"
label var gender "Gender"
label var edu "University degree"
label var income "Monthly household income"
label var province "Province"

* moderator
rename dc22_truck_con_prote freedom
replace freedom=. if freedom==-99
fre freedom

* recode moderator to binary
gen free_b=.
replace free_b=0 if freedom==1  | freedom==2
replace free_b=1 if freedom==3  | freedom==4
label define lbfree_b  0"Strongly agree/Somewhat agree" 1"Somewhat disagree/Strongly disagree" 
label values free_b lbfree_b
fre free_b

************************
**# Summary statistics *
************************
fre vote_2021 // Table A.2.1
asdoc sum lpc_demo cpc_demo ndp_demo gr_demo ppc_demo freedom age gender edu income, replace tzok dec(2) save(sumstat.rtf) // Table A.2.2
fre province // Table A.2.3

* missing rate of perceived democraticness // Table A.3
fre lpc_demo cpc_demo ndp_demo gr_demo ppc_demo
fre lpc_demo cpc_demo ndp_demo gr_demo ppc_demo if tr==0
fre lpc_demo cpc_demo ndp_demo gr_demo ppc_demo if tr!=0

*****************************
**# Covariate balance tests *
*****************************
* Treatment: LPC undemocratic prime (Figure B.3.1)
eststo age_1: reg tr age if tr!=2
eststo edu_1: reg tr edu if tr!=2
eststo income_1: reg tr income if tr!=2
eststo gender1_1: reg tr 1.gender if tr!=2 
eststo gender2_1: reg tr 2.gender if tr!=2
eststo gender3_1: reg tr 3.gender if tr!=2
forvalues i=1/12{
	eststo province`i'_1: reg tr `i'.province if tr!=2
}

coefplot age_1 edu_1 income_1 gender1_1 gender2_1 gender3_1 ///
	province1_1 province2_1 province3_1 province4_1 province5_1 province6_1 province7_1 province8_1 province9_1 province10_1 province11_1 province12_1 , ///
	drop(_cons) xtitle("Estimate") xline(0, lpattern(l)) legend(off) mcolor(black)  ciopts(lcolor(black)) offset(0) ///
	headings( 1.gender="{bf:Gender}" 1.province="{bf:Province}", labsize(3)) ///
	mlabel format(%9.2g) mlabposition(1) mlabgap(*1)
graph export "covariate balance_1.png", as(png) replace 


* Treatment: CPC undemocratic prime (Figure B.3.2)
eststo age_2: reg tr age if tr!=1
eststo edu_2: reg tr edu if tr!=1
eststo income_2: reg tr income if tr!=1
eststo gender1_2: reg tr 1.gender if tr!=1
eststo gender2_2: reg tr 2.gender if tr!=1
eststo gender3_2: reg tr 3.gender if tr!=1
forvalues i=1/12{
	eststo province`i'_2: reg tr `i'.province if tr!=1
}

coefplot age_2 edu_1 income_2 gender1_2 gender2_2 gender3_2 ///
	province1_2 province2_2 province3_2 province4_2 province5_2 province6_2 province7_2 province8_2 province9_2 province10_2 province11_2 province12_2 , ///
	drop(_cons) xtitle("Estimate") xline(0, lpattern(l)) legend(off) mcolor(black)  ciopts(lcolor(black)) offset(0) ///
	headings( 1.gender="{bf:Gender}" 1.province="{bf:Province}", labsize(3)) ///
	mlabel format(%9.2g) mlabposition(1) mlabgap(*1)
graph export "covariate balance_2.png", as(png) replace 

**************************************************************
**# Descriptives of perceived democraticness (Control group) *
**************************************************************
* lpc voters
foreach x in lpc_demo cpc_demo ndp_demo gr_demo ppc_demo{
    eststo `x'_1: reg `x' if tr==0 & vote_2021==1 
	margins, saving(`x'_1,replace) 
}
combomarginsplot lpc_demo_1 cpc_demo_1 ndp_demo_1 gr_demo_1 ppc_demo_1, horizontal ///
	labels("LPC" "CPC" "NDP" "Green" "PPC") ///
	xtitle("") xlabel(0 `""undemocratic" "(0)""' 10 `""democratic" "(10)""') ///
	ytitle("") yscale(reverse) title("LPC voters (n=94)", box bexpand bcolor("gs10%30"))  recast(scatter) ///
	plot1opts(lcolor() mcolor(plr1)) ci1opts(lcolor(plr1)) saving(lpc_voters, replace) graphregion(margin(r+5 l-5))

* cpc voters 
foreach x in lpc_demo cpc_demo ndp_demo gr_demo ppc_demo{
    eststo `x'_2: reg `x' if tr==0 & vote_2021==2 
	margins, saving(`x'_2,replace) 
}
combomarginsplot lpc_demo_2 cpc_demo_2 ndp_demo_2 gr_demo_2 ppc_demo_2, horizontal ///
	labels("LPC" "CPC" "NDP" "Green" "PPC") ///
	xtitle("") xlabel(0 `""undemocratic" "(0)""' 10 `""democratic" "(10)""') ///
	ytitle("") yscale(reverse) title("CPC voters (n=115)", box bexpand bcolor("gs10%30"))  recast(scatter) ///
	plot1opts(lcolor(sea) mcolor(sea)) ci1opts(lcolor(sea)) saving(cpc_voters, replace)  graphregion(margin(r+5 l-5))

* ndp voters
foreach x in lpc_demo cpc_demo ndp_demo gr_demo ppc_demo{
    eststo `x'_3: reg `x' if tr==0 & vote_2021==3 
	margins, saving(`x'_3,replace) 
}
combomarginsplot lpc_demo_3 cpc_demo_3 ndp_demo_3 gr_demo_3 ppc_demo_3, horizontal ///
	labels("LPC" "CPC" "NDP" "Green" "PPC") ///
	xtitle("") xlabel(0 `""undemocratic" "(0)""' 10 `""democratic" "(10)""') ///
	ytitle("") yscale(reverse) title("NDP voters (n=68)", box bexpand bcolor("gs10%30"))  recast(scatter) ///
	plot1opts(lcolor("224 137 38") mcolor("224 137 38")) ci1opts(lcolor("224 137 38")) saving(ndp_voters, replace) 	graphregion(margin(r+5 l-5))
	
* green voters
foreach x in lpc_demo cpc_demo ndp_demo gr_demo ppc_demo{
    eststo `x'_5: reg `x' if tr==0 & vote_2021==5 
	margins, saving(`x'_5,replace) 
}
combomarginsplot lpc_demo_5 cpc_demo_5 ndp_demo_5 gr_demo_5 ppc_demo_5, horizontal ///
	labels("LPC" "CPC" "NDP" "Green" "PPC") ///
	xtitle("") xlabel(0 `""undemocratic" "(0)""' 10 `""democratic" "(10)""') ///
	ytitle("") yscale(reverse) title("Green voters (n=20)", box bexpand bcolor("gs10%30"))  recast(scatter) ///
	plot1opts(lcolor(turquoise) mcolor(turquoise)) ci1opts(lcolor(turquoise)) saving(gr_voters, replace) graphregion(margin(r+5 l-5))
	
* ppc voters
foreach x in lpc_demo cpc_demo ndp_demo gr_demo ppc_demo{
    eststo `x'_6: reg `x' if tr==0 & vote_2021==6 
	margins, saving(`x'_6,replace) 
}
combomarginsplot lpc_demo_6 cpc_demo_6 ndp_demo_6 gr_demo_6 ppc_demo_6, horizontal ///
	labels("LPC" "CPC" "NDP" "Green" "PPC") ///
	xtitle("") xlabel(0 `""undemocratic" "(0)""' 10 `""democratic" "(10)""') ///
	ytitle("") yscale(reverse) title("PPC voters (n=7)", box bexpand bcolor("gs10%30"))  recast(scatter) ///
	plot1opts(lcolor(pll1) mcolor(pll1)) ci1opts(lcolor(pll1)) saving(ppc_voters, replace) graphregion(margin(r+5 l-5))
	
* abstainers
foreach x in lpc_demo cpc_demo ndp_demo gr_demo ppc_demo{
    eststo `x'_7: reg `x' if tr==0 & vote_2021==7 
	margins, saving(`x'_7,replace) 
}
combomarginsplot lpc_demo_7 cpc_demo_7 ndp_demo_7 gr_demo_7 ppc_demo_7, horizontal ///
	labels("LPC" "CPC" "NDP" "Green" "PPC") ///
	xtitle("") xlabel(0 `""undemocratic" "(0)""' 10 `""democratic" "(10)""') ///
	ytitle("") yscale(reverse) title("Abstainers (n=34)", box bexpand bcolor("gs10%30"))  recast(scatter) ///
	plot1opts(lcolor(gs10) mcolor(gs10)) ci1opts(lcolor(gs10)) saving(abstainers, replace) graphregion(margin(r+5 l-5))

* graph combine
graph combine lpc_voters.gph cpc_voters.gph ndp_voters.gph gr_voters.gph ppc_voters.gph abstainers.gph, r(2) 
graph export voters_combined.png, replace

* paired t-tests (Table C.1)
foreach var in cpc_demo ndp_demo gr_demo ppc_demo {
	ttest lpc_demo == `var' if tr==0 & vote_2021==1
}
foreach var in lpc_demo ndp_demo gr_demo ppc_demo {
	ttest cpc_demo == `var' if tr==0 & vote_2021==2
}
foreach var in lpc_demo cpc_demo gr_demo ppc_demo {
	ttest ndp_demo == `var' if tr==0 & vote_2021==3
}
foreach var in lpc_demo cpc_demo ndp_demo ppc_demo {
	ttest gr_demo== `var' if tr==0 & vote_2021==5
}
foreach var in lpc_demo cpc_demo ndp_demo gr_demo {
	ttest ppc_demo == `var' if tr==0 & vote_2021==6
}

foreach var in lpc_demo cpc_demo ndp_demo gr_demo ppc_demo {
	sum `var' if tr==0 & vote_2021==7
}	
	
*************************
**# Experiment analysis *
*************************
* drop respondents who failed manipulation checks
fre mcheck // Table B.1
drop if mcheck==-99 | mcheck==1 | mcheck==3 

*--------------------------------*
* Main analysis (Pre-registered) *
*--------------------------------*
global control c.age i.gender i.edu i.province c.income // declare control variables

* LPC undemocratic prime
reg lpc_demo i.tr##i.vote_2021 $control if vote_2021<=2 & tr!=2
margins if vote_2021==1, dydx(tr) post
est store lpc_voter
reg lpc_demo i.tr##i.vote_2021 $control if vote_2021<=2 & tr!=2
margins if vote_2021==2, dydx(tr) post
est store cpc_voter
coefplot (lpc_voter, msymbol(D) mlcolor("plr1") mfcolor("plr1") ciopts(lcolor("plr1"))) ///
	(cpc_voter,  msymbol(Th)  mlcolor("sea") mfcolor("sea") ciopts(lcolor("sea"))), ///
	keep(1.tr 1.tr##2.vote_2021) saving(lpc_tr1, replace) ///
	vertical ylabel(-1.5(0.5)1.5)  title("(A) Placement of LPC by LPC and CPC voters", size(medium))  xlabel(1 " " ) /// 
	ytitle("{bf:AME of LPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "LPC voters") label(4 "CPC voters")) 
graph export lpc_tr1.png, replace		

* CPC undemocratic prime	
reg cpc_demo i.tr##i.vote_2021 $control if vote_2021<=2 & tr!=1 
margins if vote_2021==1, dydx(tr) post
est store lpc_voter
reg cpc_demo i.tr##i.vote_2021 $control if vote_2021<=2 & tr!=1 
margins if vote_2021==2, dydx(tr) post
est store cpc_voter
coefplot (lpc_voter, msymbol(D) mlcolor("plr1") mfcolor("plr1") ciopts(lcolor("plr1"))) ///
	(cpc_voter,  msymbol(Th)  mlcolor("sea") mfcolor("sea") ciopts(lcolor("sea"))), ///
	keep(2.tr 2.tr##2.vote_2021) saving(cpc_tr2, replace) ///
	vertical ylabel(-1.5(0.5)1.5)  title("(B) Placement of CPC by LPC and CPC voters", size(medium))  xlabel(1 " " ) ///
	ytitle("{bf:AME of CPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "LPC voters") label(4 "CPC voters")) 
graph export cpc_tr2.png, replace	

grc1leg lpc_tr1.gph cpc_tr2.gph, graphregion(margin(r+5))
graph export "lpc_tr1+cpc_tr2.png", replace	// Figure 2 in the paper

* ------------------------------------------------------------------------------
* Table C.2
* LPC undemocratic prime
reg lpc_demo i.tr##i.vote_2021 $control if vote_2021<=2 & tr!=2
eststo dydx_tr1: margins, dydx(tr) by(vote_2021) post
quietly estadd local ctrl "Yes": dydx_tr1

* CPC undemocratic prime
reg cpc_demo i.tr##i.vote_2021 $control if vote_2021<=2 & tr!=1 
eststo dydx_tr2: margins, dydx(tr) by(vote_2021) post
quietly estadd local ctrl "Yes": dydx_tr2

esttab dydx_tr1 dydx_tr2 using "main_dydx.rtf", b(2) se(2) replace ///
	scalars("ctrl Controls" "N Observations") 	///
	label wide onecell noomitted nonumbers  lines  varwidth(25) ///
	mtitles("(1) Placement of LPC" "(2) Placement of CPC"  modelwidth(28 28)) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are the average marginal effect of exposure to a party's undemocratic prime. Standard errors are shown in parentheses. The dependent variable has a scale ranging from 0-10, where 0 means 'undemocratic' and 10 means 'democratic'. Controls (age, gender, province, education, education, and income) are omitted from the table.") ///
	title("Table C.2. Treatment effects of exposure to a party's undemocratic prime (LPC voters and CPC voters)") 

* ------------------------------------------------------------------------------	
* equivalence tests
sum lpc_demo if vote_2021==1 & tr==1 // LPC voters (treatment group)
sum lpc_demo if vote_2021==1 & tr==0 // LPC voters (control group)

sum cpc_demo if vote_2021==2 & tr==2 // CPC voters (treatment group) 
sum cpc_demo if vote_2021==2 & tr==0 // CPC voters (control group)
* The above codes are for obtaining the sample size, means and standard deviations for the equivalence tests
* Readers may refer to the files "Equivalence_Tests_tr1_LPC_voters" & "Equivalence_Tests_tr2_CPC_voters" for the equivalence tests analysis

*-------------------------------------------------------------------------------------------------*
* Moderator: The protesters were protecting Canadians' rights and freedoms (Exploratory analysis) *
*-------------------------------------------------------------------------------------------------*
* distribution of moderator in ordinal scale (among LPC voters and CPC voters)
fre freedom if vote_2021==1
fre freedom if vote_2021==2 

* LPC undemocratic prime
reg lpc_demo i.tr##i.freedom $control if vote_2021==2 & tr!=2 
eststo dydx_tr1_freedom_cpc_voter: margins if vote_2021==2, dydx(tr) at(freedom=(1(1)4)) post
quietly estadd local ctrl "Yes": dydx_tr1_freedom_cpc_voter
sum lpc_demo if vote_2021==2
display 2.366654/3.160088 // treatment effect in SD
coefplot (dydx_tr1_freedom_cpc_voter,  msymbol(Th)  mlcolor("sea") mfcolor("sea") ciopts(lcolor("sea"))), ///
	keep(1._at 2._at 3._at 4._at) saving(tr1_freedom_cpc_voter, replace) ///
	vertical ylabel(-4(1)4) title("(A) Placement of LPC by CPC voters", size(medium)) xlabel(1 "Strongly agree" 2 "Somewhat agree" 3 "Somewhat disagree" 4 "Strongly disagree", alternate) ///
	ytitle("{bf:AME of LPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "CPC voters")) 


* CPC undemocratic prime
reg cpc_demo i.tr##i.freedom $control if vote_2021==1 & tr!=1 
eststo dydx_tr2_freedom_lpc_voter: margins if vote_2021==1, dydx(tr) at(freedom=(1(1)4)) post
quietly estadd local ctrl "Yes": dydx_tr2_freedom_lpc_voter
sum cpc_demo if vote_2021==1
display 1.19837/2.781521 // treatment effect in SD
coefplot (dydx_tr2_freedom_lpc_voter,  msymbol(D)  mlcolor("plr1") mfcolor("plr1") ciopts(lcolor("plr1"))), ///
	keep(1._at 2._at 3._at 4._at) saving(tr2_freedom_lpc_voter, replace) ///
	vertical ylabel(-4(1)4) title("(B) Placement of CPC by LPC voters", size(medium))  xlabel(1 "Strongly agree" 2 "Somewhat agree" 3 "Somewhat disagree" 4 "Strongly disagree", alternate) ///
	ytitle("{bf:AME of CPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "LPC voters")) 

graph combine tr1_freedom_cpc_voter.gph tr2_freedom_lpc_voter.gph
graph export "freedom_cpc_voter+lpc_voter.png", replace	// Figure 3 in the paper
	
* ------------------------------------------------------------------------------
* Table C.4
esttab dydx_tr1_freedom_cpc_voter dydx_tr2_freedom_lpc_voter using "freedom_dydx.rtf", b(2) se(2) replace ///
	scalars("ctrl Controls" "N Observations") 	///
	label wide onecell noomitted nonumbers  lines  varwidth(25) ///
	mtitles("(1) Placement of LPC by CPC voters" "(2) Placement of CPC by LPC voters"  modelwidth(28 28)) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	coeflabel(1._at "Strongly agree" 2._at "Somewhat agree" 3._at "Somewhat disagree" 4._at "Strongly disagree") ///
	note("Note: Entries are the average marginal effect of exposure to a party's undemocratic prime. Standard errors are shown in parentheses. The dependent variable has a scale ranging from 0-10, where 0 means 'undemocratic' and 10 means 'democratic'. The moderator variable has a four-point ordinal scale, which asks respondents how much they agree 'the protesters were protecting Canadians' rights and freedoms'. Controls (age, gender, province, education, education, and income) are omitted from the table.") ///
	title("Table C.4. Moderating effect of attitude towards the convoy (LPC voters and CPC voters)") 


* Sensitivity analysis: binary moderator 
reg lpc_demo i.tr##i.free_b $control if vote_2021==2 & tr!=2 
eststo dydx_tr1_free_b_cpc_voter: margins if vote_2021==2, dydx(tr) at(free_b=(0 1)) post
quietly estadd local ctrl "Yes": dydx_tr1_free_b_cpc_voter
coefplot (dydx_tr1_free_b_cpc_voter,  msymbol(Th)  mlcolor("sea") mfcolor("sea") ciopts(lcolor("sea"))), ///
	keep(1._at 2._at) saving(tr1_free_b_cpc_voter, replace) ///
	vertical ylabel(-4(1)4) title("(A) Placement of LPC by CPC voters", size(medium)) xlabel(1 `""Strongly agree/" "Somewhat agree""' 2 `""Somewhat disagree/" "Strongly disagree""') ///
	ytitle("{bf:AME of LPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "CPC voters")) 

	
reg cpc_demo i.tr##i.free_b $control if vote_2021==1 & tr!=1 
eststo dydx_tr2_free_b_lpc_voter: margins if vote_2021==1, dydx(tr) at(free_b=(0 1)) post
quietly estadd local ctrl "Yes": dydx_tr2_free_b_lpc_voter	
coefplot (dydx_tr2_free_b_lpc_voter	,  msymbol(D)  mlcolor("plr1") mfcolor("plr1") ciopts(lcolor("plr1"))), ///
	keep(1._at 2._at 3._at 4._at) saving(tr2_free_b_lpc_voter, replace) ///
	vertical ylabel(-4(1)4) title("(B) Placement of CPC by LPC voters", size(medium))  xlabel(1 `""Strongly agree/" "Somewhat agree""' 2 `""Somewhat disagree/" "Strongly disagree""') ///
	ytitle("{bf:AME of CPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "LPC voters")) 

graph combine tr1_free_b_cpc_voter.gph tr2_free_b_lpc_voter.gph
graph export "free_b_cpc_voter+lpc_voter.png", replace	// Table C.2	
	
	
* ------------------------------------------------------------------------------
* Table C.5
esttab dydx_tr1_free_b_cpc_voter dydx_tr2_free_b_lpc_voter using "free_b_dydx.rtf", b(2) se(2) replace ///
	scalars("ctrl Controls" "N Observations") 	///
	label wide onecell noomitted nonumbers  lines  varwidth(25) ///
	mtitles("(1) Placement of LPC by CPC voters" "(2) Placement of CPC by LPC voters"  modelwidth(28 28)) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	coeflabel(1._at "Strongly agree/Somewhat agree" 2._at "Somewhat disagree/Strongly disagree") ///
	note("Note: Entries are the average marginal effect of exposure to a party's undemocratic prime. Standard errors are shown in parentheses. The dependent variable has a scale ranging from 0-10, where 0 means 'undemocratic' and 10 means 'democratic'. the moderator variable has a binary scale: 'Strongly agree' and 'Somewhat agree' are coded as 0, whereas 'Somewhat disagree' and 'Strongly disagree' are coded as 1. The question asks respondents how much they agree 'the protesters were protecting Canadians' rights and freedoms'. Controls (age, gender, province, education, education, and income) are omitted from the table.") ///
	title("Table C.5. Recoding the moderator to binary (LPC voters and CPC voters)") 	

	
*-----------------------------------------------------------------------*
* Treatment effect among NDP voters & abstainers (Exploratory analysis) *
*-----------------------------------------------------------------------*
* LPC undemocratic prime
reg lpc_demo i.tr##i.vote_2021 $control if (vote_2021==3 | vote_2021==7) & tr!=2 
margins if vote_2021==3, dydx(tr) post
est store ndp_voter_tr1

reg lpc_demo i.tr##i.vote_2021 $control if (vote_2021==3 | vote_2021==7) & tr!=2 
margins if vote_2021==7, dydx(tr) post
est store abs_tr1

coefplot (ndp_voter_tr1, msymbol(O) mlcolor("224 137 38") mfcolor("224 137 38") ciopts(lcolor("224 137 38"))) ///
	(abs_tr1, msymbol(S) mlcolor(gs10) mfcolor(gs10) ciopts(lcolor(gs10))), ///
	keep(1.tr) saving(ndp+abs_tr1, replace) ///
	vertical ylabel(-1.5(0.5)1.5)  title("(A) Placement of LPC by NDP voters and Abstainers", size(medium))  xlabel(1 " " ) ///
	ytitle("{bf:AME of LPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "NDP voters") label(4 "Abstainers")) graphregion(margin(r+5)) 

* CPC undemocratic prime
reg cpc_demo i.tr##i.vote_2021 $control if (vote_2021==3 | vote_2021==7) & tr!=1
margins if vote_2021==3, dydx(tr) post
est store ndp_voter_tr2

reg cpc_demo i.tr##i.vote_2021 $control if (vote_2021==3 | vote_2021==7) & tr!=1
margins if vote_2021==7, dydx(tr) post
est store abs_tr2
	
coefplot (ndp_voter_tr2, msymbol(O) mlcolor("224 137 38") mfcolor("224 137 38") ciopts(lcolor("224 137 38"))) ///
	(abs_tr2, msymbol(S) mlcolor(gs10) mfcolor(gs10) ciopts(lcolor(gs10))), ///
	keep(2.tr) saving(ndp+abs_tr2, replace) ///
	vertical ylabel(-1.5(0.5)1.5)  title("(B) Placement of CPC by NDP voters and Abstainers", size(medium))  xlabel(1 " " ) ///
	ytitle("{bf:AME of CPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "NDP voters") label(4 "Abstainers")) graphregion(margin(r+5))
	
grc1leg ndp+abs_tr1.gph ndp+abs_tr2.gph 
graph export "ndp+abs_tr1+tr2.png", replace	// Figure C.1	

* ------------------------------------------------------------------------------
* Table C.3
* LPC undemocratic prime
reg lpc_demo i.tr##i.vote_2021 $control if (vote_2021==3 | vote_2021==7) & tr!=2
eststo dydx_tr1: margins, dydx(tr) by(vote_2021) post
quietly estadd local ctrl "Yes": dydx_tr1

* CPC undemocratic prime
reg cpc_demo i.tr##i.vote_2021 $control if (vote_2021==3 | vote_2021==7) & tr!=1 
eststo dydx_tr2: margins, dydx(tr) by(vote_2021) post
quietly estadd local ctrl "Yes": dydx_tr2

esttab dydx_tr1 dydx_tr2 using "ndp+abs_dydx.rtf", b(2) se(2) replace ///
	scalars("ctrl Controls" "N Observations") 	///
	label wide onecell noomitted nonumbers  lines  varwidth(25) ///
	mtitles("(1) Placement of LPC" "(2) Placement of CPC"  modelwidth(28 28)) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	note("Note: Entries are the average marginal effect of exposure to a party's undemocratic prime. Standard errors are shown in parentheses. The dependent variable has a scale ranging from 0-10, where 0 means 'undemocratic' and 10 means 'democratic'. Controls (age, gender, province, education, education, and income) are omitted from the table.") ///
	title("Table C.3. Treatment effects of exposure to a party's undemocratic prime (NDP voters and Abstainers)") 



* moderator
* LPC undemocratic prime
reg lpc_demo i.tr##i.freedom $control if vote_2021==3 & tr!=2
eststo dydx_tr1_freedom_ndp_voters: margins if vote_2021==3, dydx(tr) at(freedom=(1(1)4)) post
quietly estadd local ctrl "Yes": dydx_tr1_freedom_ndp_voters

reg lpc_demo i.tr##i.freedom $control if  vote_2021==7 & tr!=2
eststo dydx_tr1_freedom_abs: margins if vote_2021==7, dydx(tr) at(freedom=(1(1)4)) post
quietly estadd local ctrl "Yes": dydx_tr1_freedom_abs


coefplot (dydx_tr1_freedom_ndp_voters,  msymbol(O)  mlcolor("224 137 38") mfcolor("224 137 38") ciopts(lcolor("224 137 38"))) ///
	(dydx_tr1_freedom_abs,  msymbol(S)  mlcolor(gs10) mfcolor(gs10) ciopts(lcolor(gs10))), ///
	keep(1._at 2._at 3._at 4._at) saving(tr1_freedom_ndp_voter+abs, replace) ///
	vertical ylabel(-5(1)7) title("(A) Placement of LPC by NDP voters and Abstainers", size(medium))  xlabel(1 "Strongly agree" 2 "Somewhat agree" 3 "Somewhat disagree" 4 "Strongly disagree", alternate) ///
	ytitle("{bf:AME of LPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "NDP voters") label(4 "Abstainers")) 


* CPC undemocratic prime
reg cpc_demo i.tr##i.freedom $control if vote_2021==3 & tr!=1 
eststo dydx_tr2_freedom_ndp_voters: margins if vote_2021==3, dydx(tr) at(freedom=(1(1)4)) post
quietly estadd local ctrl "Yes": dydx_tr2_freedom_ndp_voters

reg cpc_demo i.tr##i.freedom $control if vote_2021==7 & tr!=1 
eststo dydx_tr2_freedom_abs: margins if vote_2021==7, dydx(tr) at(freedom=(1(1)4)) post
quietly estadd local ctrl "Yes": dydx_tr2_freedom_abs

coefplot (dydx_tr2_freedom_ndp_voters,  msymbol(O)  mlcolor("224 137 38") mfcolor("224 137 38") ciopts(lcolor("224 137 38"))) ///
	(dydx_tr2_freedom_abs,  msymbol(S)  mlcolor(gs10) mfcolor(gs10) ciopts(lcolor(gs10))), ///
	keep(1._at 2._at 3._at 4._at) saving(tr2_freedom_ndp_voter+abs, replace) ///
	vertical ylabel(-5(1)7) title("(A) Placement of CPC by NDP voters and Abstainers", size(medium))  xlabel(1 "Strongly agree" 2 "Somewhat agree" 3 "Somewhat disagree" 4 "Strongly disagree", alternate) ///
	ytitle("{bf:AME of CPC undemocratic prime}") yline(0) legend(pos(6) row(1) label(2 "NDP voters") label(4 "Abstainers"))

graph combine tr1_freedom_ndp_voter+abs.gph tr2_freedom_ndp_voter+abs.gph
graph export "freedom_ndp+abs.png", replace	// Figure C.3


* ------------------------------------------------------------------------------
* Table C.6
esttab dydx_tr1_freedom_ndp_voters dydx_tr1_freedom_abs  dydx_tr2_freedom_ndp_voters dydx_tr2_freedom_abs using "freedom_dydx_ndp+abs.rtf", b(2) se(2) replace ///
	scalars("ctrl Controls" "N Observations") 	///
	label wide onecell noomitted nonumbers  lines  varwidth(15) ///
	mtitles("(1) Placement of LPC by NDP voters" "(2) Placement of LPC by Abstainers" "(3) Placement of CPC by NDP voters" "(4) Placement of CPC by Abstainers"  modelwidth(24 24 24 24)) ///
	star(+ 0.10 * 0.05 ** 0.01 *** 0.001)  ///
	coeflabel(1._at "Strongly agree" 2._at "Somewhat agree" 3._at "Somewhat disagree" 4._at "Strongly disagree") ///
	note("Note: Entries are the average marginal effect of exposure to a party's undemocratic prime. Standard errors are shown in parentheses. The dependent variable has a scale ranging from 0-10, where 0 means 'undemocratic' and 10 means 'democratic'. The moderator variable has a four-point ordinal scale, which asks respondents how much they agree 'the protesters were protecting Canadians' rights and freedoms'. Controls (age, gender, province, education, education, and income) are omitted from the table.") ///
	title("Table C.6. Moderating effect of attitude towards the convoy (NDP voters and Abstainers)") 
	